"""
    This file defines those interfaces checking dict.
    To check the data in request.
"""

import utils


UPLOAD_MOVES_CHECKING = {
    'problem_id' : utils.Constrain(int, lambda x : x >= 1 and x <= 65535),
    'username' : str,
    'move_list' : utils.Constrain(list, lambda l : len(l) >= 0, {
        'car_index': utils.Constrain(int, lambda x : 0 <= x and x <= 65535),
        'old': {
            'x': int,
            'y': int
        },
        'new': {
            'x': int,
            'y': int
        }
    })
}


UPLOAD_PROBLEM_CHECKING = {
    'designer' : str,
    'description' : str,
    'cars' : utils.Constrain(list, lambda l : len(l) >= 0, {
        'position' : {
            'x' : utils.Constrain(int, lambda x : x >= 0 and x < 6),
            'y' : utils.Constrain(int, lambda x : x >= 0 and x < 6),
        },
        'length' : utils.Constrain(int, lambda x : x in {2, 3}),
        'allow_direction' : utils.Constrain(str, lambda s : s in {'x', 'y'})
    })
}